/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package model.creature.sprite.plugin;

import java.awt.Image;
import model.creature.moving_creature.ActionType;
import model.creature.moving_creature.Direction;
import model.creature.sprite.DefaultSprite;
import model.game.GameInterface;
import model.map.cell.Cell;
import model.utility.ImageUtility;

/**
 * Produces money.
 * However it is stressed and will place itself near enemies.
 */
public class Banker extends DefaultSprite {

  /**
   * Constructor
   */
  public Banker(GameInterface game) {
    super(game, game.getMaps().getField().getCellAt(1,1));
  }

  @Override
  public int getHiringPrice() {
    return 400 + getLevel() * 250;
  }

  @Override
  public String getName() {
    return "Banker";
  }

  @Override
  public String getDescription() {
    return "Lv: " + getLevel() + ", MaxHP: " + getMaxHP() + ", " +
    "Produces " + 
            game_.getConstants().getFormattedMoney(getProducedMoney()) +
            " everyday. However, her job is stressing and so she tends to "
            + "walk near dangerous monsters.";
  }

  @Override
  public Image getImage() {
    return ImageUtility.loadImage("resources/pictures/sprite/banker/banker.png");
  }

  @Override
  public boolean canUpgrade() {
    if (getLevel() < 10) return true;
    return false;
  }

  @Override
  public int getUpgradeCost() {
    return 100 + getLevel() * 100;
  }

  @Override
  public int getMaxHP() {
    return 100 + getLevel() * 50;
  }

  @Override
  protected ActionType getActionType(Cell cell, Direction dir) {
    return ActionType.kActionStay;
  }

  @Override
  protected int howImportantIsFacingThis(Cell cell) {
    if (game_.getCreatures().getMonsters().getAllMonstersAt(cell).isEmpty()) return 0;
    return 1;
  }

  @Override
  protected int howImportantIsBeingHere (Cell cell, Direction dir) {
    return 0;
  }

  private int getProducedMoney() {
    int base = 100;
    for (int i = 0; i < getLevel(); ++i) {
      base += (i+1) * 25;
    }
    return base;
  }

  @Override
  public void advanceDay() {
    if (isHired()) {
      game_.getInventory().addMoney(getProducedMoney());
      game_.addImportantMessage(this.getName() + " produces " + 
              game_.getConstants().getFormattedMoney(getProducedMoney()));
    }
  }

}
